package com.rtf.framework.common.dto.params;

import com.rtf.framework.common.util.UtilAppProperties;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Setter
@Getter
public class AppBasePageParam implements Serializable {

    private static final long serialVersionUID = 1L ;

    private Integer pageNum = 0;

    private Integer pageSize = 10;

    public Integer getPageSize(){
        if(this.pageSize==null){
            this.pageSize = 15;
        }
        return this.pageSize;
    }

    public Integer getPageNum(){
        //前端传递的分页号，如果是从0开始，则直接向后端传递；否则减去1后再向后端传递
        if( UtilAppProperties.appProperties.getPageConfig().getFrontPageNumStartFromZero() ){
            return pageNum < 0 ? 0 : pageNum ;
        }else if( pageNum == 0 ){
            return 0 ;
        }else{
            return pageNum -1 ;
        }
    }

}

